"""
 -*- coding: utf-8-*-
 @File: page_create.py
 @Author: chen
 @time: 2023/12/03/ 11:29
"""
import time

from stage_L1.lim_project.page_po.businesses.page_base import BasePage
from stage_L1.lim_project.page_po.utils.mgt_logger import logger


class CreatePage(BasePage):
    def input_name(self, project_name):
        """输入项目名称"""
        _input_name = (self.BY.ID, 'name')
        logger.info("输入项目名称")
        self.do_input(_input_name, project_name)
        return self

    def click_ensure(self):
        """点击确定按钮"""
        _btn_ensure = (self.BY.XPATH, '//*[text()="确 定"]')
        _btn_cancel = (self.BY.XPATH, '//*[text()="取 消"]')
        self.do_click(_btn_ensure)
        try:
            self.do_click(_btn_cancel)
            logger.info("点击取消按钮--->页面跳转成功")
        except:
            logger.info("点击确定按钮--->页面跳转成功")
        from stage_L1.lim_project.page_po.businesses.page_project.page_project_mgt import ProjectMgtPage
        logger.info("回到项目管理页面")
        return ProjectMgtPage(self.driver)
